﻿namespace IndicatorsTest.Utils
{
	using System;

	using Ecng.Common;

	using StockSharp.Algo.Indicators;

	class TestIndicatorValue<TInner> : IIndicatorValue
	{
		private readonly TInner _value;

		public TestIndicatorValue(TInner value)
		{
			_value = value;
		}

		public bool IsFinal
		{
			get { return true; }
		}

		public bool IsEmpty
		{
			get { return false; }
		}

		bool IIndicatorValue.IsSupport(Type valueType)
		{
			return valueType == typeof(TInner);
		}

		T IIndicatorValue.GetValue<T>()
		{
			return _value.To<T>();
		}

		IIndicatorValue IIndicatorValue.SetValue<T>(T value)
		{
			return new TestIndicatorValue<T>(value);
		}
	}
}